package cn.wjc.demo.common.controller;

import cn.wjc.demo.common.annotation.FileParam;
import cn.wjc.demo.common.annotation.FileValid;
import cn.wjc.demo.common.annotation.JustAnnotation;
import cn.wjc.demo.common.annotation.TestAnnotation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/file")
@Slf4j
public class AopTestController {

    @PostMapping("/upload")
    @FileValid
    public String upload(@FileParam(suffix = {"doc","txt"})MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
        log.debug("in the method");
        return "success";
    }

    @PostMapping("/testAnnotation")
    @TestAnnotation
    public void testAnnotation() {
        log.info("执行【testAnnotation】请求");
    }

    @PostMapping("/justAnnotation")
    @JustAnnotation
    public void justAnnotation() {
        log.info("执行【justAnnotation】请求");
    }
}
